package com.imut.lagain.entity;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.annotation.*;
import jakarta.persistence.Column;
import jakarta.persistence.PreUpdate;
import java.time.LocalDateTime;

/**
 * 感官练习实体类
 */
@TableName("sensory_exercise")
public class SensoryExercise {
    private static final Logger log = LoggerFactory.getLogger(SensoryExercise.class);

    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("user_id")
    private Long userId;

    @TableField("session_id")
    private String sessionId;

    @TableField("exercise_type")
    private String exerciseType; // 5-4-3-2-1/grounding/mindfulness

    @TableField("sense_focus")
    private String senseFocus; // sight/sound/touch/smell/taste/all

    @TableField("items_identified")
    private String itemsIdentified; // JSON格式存储识别的物品

    @TableField("start_time")
    private LocalDateTime startTime;

    @TableField("end_time")
    private LocalDateTime endTime;

    @TableField("duration_seconds")
    private Integer durationSeconds;

    @TableField("status")
    private String status; // active/completed/paused/abandoned

    @TableField("effectiveness_rating")
    private Integer effectivenessRating;

    @TableField("anxiety_before")
    private Integer anxietyBefore; // 1-10评分

    @TableField("anxiety_after")
    private Integer anxietyAfter; // 1-10评分

    @TableField("notes")
    private String notes;

    @TableField("environment_description")
    private String environmentDescription;

    @TableField("created_at")
    private LocalDateTime createdAt;

    @Column(name = "updated_at")
    private LocalDateTime updatedAt;

    @Column(name = "is_deleted")
    private Boolean isDeleted = false;

    public SensoryExercise() {
        this.createdAt = LocalDateTime.now();
        this.updatedAt = LocalDateTime.now();
        this.status = "pending";
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getExerciseType() {
        return exerciseType;
    }

    public void setExerciseType(String exerciseType) {
        this.exerciseType = exerciseType;
    }

    public String getSenseFocus() {
        return senseFocus;
    }

    public void setSenseFocus(String senseFocus) {
        this.senseFocus = senseFocus;
    }

    public String getItemsIdentified() {
        return itemsIdentified;
    }

    public void setItemsIdentified(String itemsIdentified) {
        this.itemsIdentified = itemsIdentified;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }

    public Integer getDurationSeconds() {
        return durationSeconds;
    }

    public void setDurationSeconds(Integer durationSeconds) {
        this.durationSeconds = durationSeconds;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Integer getEffectivenessRating() {
        return effectivenessRating;
    }

    public void setEffectivenessRating(Integer effectivenessRating) {
        this.effectivenessRating = effectivenessRating;
    }

    public Integer getAnxietyBefore() {
        return anxietyBefore;
    }

    public void setAnxietyBefore(Integer anxietyBefore) {
        this.anxietyBefore = anxietyBefore;
    }

    public Integer getAnxietyAfter() {
        return anxietyAfter;
    }

    public void setAnxietyAfter(Integer anxietyAfter) {
        this.anxietyAfter = anxietyAfter;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public String getEnvironmentDescription() {
        return environmentDescription;
    }

    public void setEnvironmentDescription(String environmentDescription) {
        this.environmentDescription = environmentDescription;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    public Boolean getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Boolean isDeleted) {
        this.isDeleted = isDeleted;
    }

    @PreUpdate
    public void preUpdate() {
        this.updatedAt = LocalDateTime.now();
    }
}